<template>
  <el-dialog :title="title" :visible.sync="showInfo" class="info-dialog" width="350px">
    <el-form :model="priceForm" :rules="pricerules" ref="priceForms" label-width="100px">
      <el-form-item label="金额：" prop="Amount">
        <el-input v-model="priceForm.Amount" ref="priceFormAmount"></el-input>
      </el-form-item>
      <el-form-item label="支付方式：" prop="CashierChannel">
        <el-select v-model="priceForm.CashierChannel" placeholder="请选择">
          <el-option
            v-for="m in CashierChannelList"
            :label="m.Name"
            :value="parseInt(m.Code)"
            :key="m.Code">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="财务备注：" prop="Remark">
        <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4}" v-model="priceForm.Remark"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="addPriceBtn('priceForms')">保存</el-button>
      <el-button @click="showInfo = false">取 消</el-button>
    </span>
  </el-dialog>
</template>
<script>
  export default {
    props:['priceForm','title','CashierChannelList'],
    data() {
      return {
        showInfo:false,
        pricerules:{
          Amount: [
            { required: true, message: '请输入金额', trigger: 'blur' },
          ],
          Remark: [
            { required: false, message: '', trigger: 'blur' },
          ],
          CashierChannel: [
            { required: true, message: '请选择支付方式', trigger: 'change' },
          ],
        },
      }
    },
    created() {
    },
    methods: {
      addPriceBtn(formName){
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$ajax.savecashierrecord(this.priceForm).then(res=>{
              if(res.Success){
                this.$refs[formName].resetFields();
                this.toggleDiolag();
                this.$emit('roomoutBeforeDown');
              }
            })
          } else {
            return false;
          }
        });
      },
      toggleDiolag(){
        this.showInfo=!this.showInfo;
      }
    }
  }

</script>
